﻿using Taype.Trading.BTC.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Configuration;

namespace MtGoxAPIClient_test
{
    
    
    /// <summary>
    ///This is b test class for MtGoxNetToolsTest and is intended
    ///to contain all MtGoxNetToolsTest Unit Tests
    ///</summary>
    [TestClass()]
    public class MtGoxNetToolsTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in b class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for MtGoxNetTools Constructor
        ///</summary>
        [TestMethod()]
        public void MtGoxNetToolsConstructorTest()
        {
            MtGoxNetTools target = new MtGoxNetTools();
            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for a valid DoAuthenticatedAPIPost
        ///</summary>
        [TestMethod()]
        public void DoAuthenticatedAPIPostTest0()
        {
            MtGoxNetTools target = new MtGoxNetTools();
            string apiKey = ConfigurationManager.AppSettings["apikey"];
            string apiSecret = ConfigurationManager.AppSettings["apiSecret"];
            string baseURL = "https://mtgox.com/api/";
            string url = (baseURL) + "0/getFunds.php";
            string actual = target.DoAuthenticatedAPIPost(url, apiKey, apiSecret, "");
            Assert.AreNotEqual("{\"error\":\"Must be logged in\"}", actual);
        }

        /// <summary>
        ///A test for DoAuthenticatedAPIPost with invalid API secret
        ///</summary>
        [ExpectedException(typeof(FormatException))]
        [TestMethod()]
        public void DoAuthenticatedAPIPostTest1()
        {
            MtGoxNetTools target = new MtGoxNetTools();
            string apiKey = ConfigurationManager.AppSettings["apikey"];
            string apiSecret = "invalid-base64-string";
            string baseURL = "https://mtgox.com/api/";
            string url = (baseURL) + "0/getFunds.php";
            target.DoAuthenticatedAPIPost(url, apiKey, apiSecret, "");
        }

        /// <summary>
        ///A test for DoAuthenticatedAPIPost with missing authentication parameters
        ///</summary>
        [ExpectedException(typeof(ArgumentException))]
        [TestMethod()]
        public void DoAuthenticatedAPIPostTest2()
        {
            MtGoxNetTools target = new MtGoxNetTools();
            string apiKey = "";
            string apiSecret = "";
            string baseURL = "https://mtgox.com/api/";
            string url = (baseURL) + "0/getFunds.php";
            target.DoAuthenticatedAPIPost(url, apiKey, apiSecret, "");
        }
    }
}
